<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="JVM Memory Monitor" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="admin" />
	</ui:define>
	<ui:define name="content">
		<h:form>
			<center>

				<p:panel header="Memory MXBean" id="uno">
					<p:panelGrid columns="2">
						<h:outputLabel for="memoryUsage" style="font-weight: bolder;"
							value="Heap Memory Usage: " />
						<h:outputText id="memoryUsage"
							value="#{memoryController.memoryUsage}" />

						<h:outputLabel for="nonMemoryUsage" style="font-weight: bolder;"
							value="Non-Heap Memory Usage: " />
						<h:outputText id="nonMemoryUsage"
							value="#{memoryController.nonMemoryUsage}" />
					</p:panelGrid>
					<br />
					<p:commandButton ajax="true" immediate="false"
						action="#{memoryController.runGc}" value="run gc"
						update="uno, due" />
				</p:panel>
				<br />
				<p:panel header="Memory Pool MXBeans" id="due">
					<p:dataTable id="memoryPool" rowIndexVar="rowIndex" var="mem"
						value="#{memoryController.memoryPool}" rows="0" paginator="false">
						<p:column width="50">
							<center>
								<h:outputText value="#{rowIndex+1} " />
							</center>
						</p:column>
						<p:column style="width: 20%;">
							<f:facet name="header">
								<h:outputText value="name" />
							</f:facet>
							<h:outputText value="#{mem.name}" />
						</p:column>
						<p:column style="width: 80%;">
							<f:facet name="header">
								<h:outputText value="values" />
							</f:facet>
							<p:panelGrid columns="2">
								<h:outputText value="type" />
								<h:outputText value="#{mem.type}" />

								<h:outputText value="usage" />
								<h:outputText value="#{mem.usage}" />

								<h:outputText value="peak usage" />
								<h:outputText value="#{mem.peakUsage}" />

								<h:outputText value="collection usage" />
								<h:outputText value="#{mem.collectionUsage}" />
							</p:panelGrid>

						</p:column>
					</p:dataTable>
				</p:panel>
			</center>
		</h:form>

	</ui:define>
</ui:composition>